package bishe;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class order {

	public static void remove(String goods) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		BufferedReader in = new BufferedReader(new FileReader("GoodsList.txt"));
		String str = null;
		while ((str = in.readLine()) != null) {
			if (str.matches("(.*)" + goods + "(.*)")) {
				continue;
			} else {
				list.add(str);
			}
		}
		in.close();
		BufferedWriter out = new BufferedWriter(new FileWriter("GoodsList.txt"));
		for (int i = 0; i < list.size(); i++) {
			out.append(list.get(i));
			out.newLine();
		}
		out.close();
	}

//用于购物车标签操作
	public static void empty() throws IOException {
		FileWriter clear = new FileWriter("GoodsList.txt");
		clear.close();
	}

	public double pay() throws IOException {
		String str = null;
		double pay = 0;
		BufferedReader in = new BufferedReader(new FileReader("GoodsList.txt"));
		while ((str = in.readLine()) != null) {
			String[] st = str.split(" ");
			pay += Double.valueOf(st[3]);
		}
		in.close();
		return pay;
	}

}
